import java.util.Random;
public class Member extends Traveller {
	private int health;
	private boolean alive;
	private boolean printed; 	// died message printed
	private boolean testingJump;
	private double jumpHeight;
	private Random rand;
	
	public Member() {
		super();
		this.health = 100;
		this.alive = true;
		this.printed = false;
		testingJump = false;
		rand = new Random();
	}
	
	public Member(String name) {
		super(name);
		this.health = 100;
		this.alive = true;
		this.printed = false;
		testingJump = false;
		rand = new Random();
	}
	
	public boolean getAlive() {
		return alive;
	}
	
	public void setAlive(boolean alive) {
		this.alive = alive;
	}
	
	public boolean getPrinted() {
		return printed;
	}
	
	public void setPrinted(boolean printed) {
		this.printed = printed;
	}
	
	public int getHealth() {
		return this.health;
	}
	
	public void setHealth(int health) {
		this.health = health;
	}
	
	/**
	 * Changes the member's health by the given amount
	 * @param amount How much to change the health. A negative number
	 * results in a decrease in health.
	 */
	public void updateHealth(int amount) {
		health = health + amount;
		if (health > 100)
			health = 100;
		if (health < 0)
			health = 0;
	}

	/**
	 * Kills the member.
	 */
	public void kill() {
		health = 0;
		alive = false;
		
	}
	
	/**
	 * Tells if the member is alive.
	 * @return True if the member is alive. False otherwise.
	 */
	public boolean isAlive() {
	
		return alive;
	}
	
	/**
	 * Simulates a jump. The jump height is random if jump testing is
	 * not activated. Jump testing can be activated with the setTestingJump method.
	 * @return How high the Member jumped in feet.
	 */
	public double jump() {
		// TODO Auto-generated method stub
		return testingJump ? jumpHeight:randomJump();
	}
	
	private double randomJump() {
		return rand.nextDouble()*6.5 + 3.0;
	}
	

	/**
	 * activates or deactivates testing behavior of the jump method.
	 * When testing is active the jump method will produce 
	 * a definite value rather than a random one.
	 * @param test True to turn on testing and false to turn it off.
	 * @param d A double to control how how the member is to jump in feet.
	 */
	public void setTestingJump(boolean test, double d)
	{
		this.testingJump = test;
		this.jumpHeight = d;
	}
}
